<template>
  <div>
    <Content style="width:90%">
      <Form :label-width="140">
        <FormItem label="分类名称" required>
          <Input v-model="supCategory.categoryName" placeholder="请输入分类名称"></Input>
        </FormItem>
        <FormItem label="分类编码" required>
          <Input v-model="supCategory.categoryCode" placeholder="请输入分类编码" />
        </FormItem>
        <FormItem label="排序" required>
          <InputNumber :min="1" v-model="supCategory.sortIndex" placeholder="请输入排序"></InputNumber>
        </FormItem>
        <FormItem label="交易模式" required>
          <RadioGroup v-model="supCategory.tradeMode">
            <Radio :label="0"><span>线上</span></Radio>
            <Radio :label="1"><span>到店</span></Radio>
          </RadioGroup>
        </FormItem>
        <FormItem label="是否为店铺分类" required>
          <RadioGroup v-model="supCategory.navStatus">
            <Radio :label="1"><span>是</span></Radio>
            <Radio :label="0"><span>否</span></Radio>
          </RadioGroup>
        </FormItem>
        <FormItem>
          <Button type="primary" @click="Submit">提交</Button>
        </FormItem>
      </Form>
    </Content>
  </div>
</template>
<script>
export default {
  name: "CategoryCreate",
  props: {
    supCategory: Object,
    callbank: Function
  },
  data() {
    return {
      
    }
  },
  created() {
    
  },
  methods: {
    Submit() {
      delete this.supCategory.putTime
      delete this.supCategory.logicDel
      delete this.supCategory.navStatusText
      delete this.supCategory.onlineText
      delete this.supCategory.tradeModeText
      delete this.supCategory.postTime
      delete this.supCategory._rowKey
      delete this.supCategory._index
      delete this.supCategory._loading
      new this.$rest({
        gateway: 'agroerp',
        service: "agroerp-shop",
        url: "/v1.0/category",
        data: {
          pojo: this.supCategory
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.$Message.success({
              content: '修改成功'
            })
            this.callbank()
          } else {
            this.$Message.error(res.data.msg)
          }
        },
      }).put()
    }
  }
}
</script>